package com.nuit.cxl.proxydemo;

import jakarta.xml.bind.SchemaOutputResolver;
import org.junit.jupiter.api.Test;

public class StaticProxyDemo {

    interface Person {
        public void doWork();

        public void sleep();
    }

    class Student implements Person {

        @Override
        public void doWork() {
            System.out.println("正在学习");
        }

        @Override
        public void sleep() {
            System.out.println("正在睡觉");
        }
    }

    class StaticProxy implements Person {
        private Person person;

        public StaticProxy(Person person) {
            this.person = person;
        }

        @Override
        public void doWork() {
            System.out.println("doSomething-----start");
            System.out.println(System.currentTimeMillis());
            person.doWork();
            System.out.println("doSomething-----end");
            System.out.println(System.currentTimeMillis());
        }

        @Override
        public void sleep() {
            System.out.println("doSomething-----start");
            System.out.println(System.currentTimeMillis());
            person.sleep();
            System.out.println("doSomething-----end");
            System.out.println(System.currentTimeMillis());
        }
    }

    @Test
    public void TestStaticProxy() {
        Person student = new Student();
        StaticProxy staticProxy = new StaticProxy(student);
        staticProxy.doWork();
    }





}
